#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <chrono>


void test_macro()
{

#define JOIN(a,b) a##b
#define CHR(a) #@a
#define STR(a) #a

	char a = 'a';
	if (a == CHR(a))
	{
		std::cout << "is match" << std::endl;
	}

	std::string aa = "second string";
	std::cout << JOIN(a, a) << std::endl;

	std::cout << STR(HelloWorld) << std::endl;

}

void test_content_erase()
{

	std::vector<int> arr = { 0,1,2,3,4,5,6,7,8,9,10 };

	int count = 0;
	for (auto it = arr.begin(); it != arr.end(); )
	{
		if (++count > 5)
		{
			it = arr.erase(it);
		}
		else
		{
			it++;
		}
	}

	std::for_each(arr.begin(), arr.end(), [](auto _n) {
		std::cout << _n << std::endl;
		});

	std::map<int, int> m = {
		{0,0}
		,{1,1}
		, {2,2}
		, {3,3}
		, {4,4}
		, {5,5}
		, {6,6}
		, {7,7}
		, {8,8}
		, {9,9}
	};
	count = 0;
	for (auto it = m.begin(); it != m.end(); )
	{
		if (++count > 5)
		{
			it++;
		}
		else
		{
			m.erase(it++);
		}
	}


	std::for_each(m.begin(), m.end(), [](auto it) {
		std::cout << it.second << std::endl;
		});

}

void test_chrono()
{

	std::chrono::duration<double, std::ratio<60 * 60>> dur{ 1.5 };
	std::cout << dur.count() << std::endl;
}

int main(int ,char* [])
{
	time_t s = time(nullptr);
	unsigned int ms = 120;
	tm* gmt = localtime(&s);
	char buf[32] = { 0 };
	strftime(buf, 32, "%Y-%m-%d %H:%M:%S", gmt);
	sprintf(buf, "%s.%u", buf, ms);
}
